package com.xx.happychatboot.middleware.rocketmq.factory.rocketmq;

import com.xx.happychatboot.middleware.rocketmq.strategy.rocketmq.AbstractRocketMqStrategy;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class RocketMqFactory {
    //策略实现类集合
    private static final Map<Integer, AbstractRocketMqStrategy> STRATEGY_MAP = new HashMap<>();

    //注册方法
    public static void register(Integer code, AbstractRocketMqStrategy rocketMqStrategy) {
        STRATEGY_MAP.put(code, rocketMqStrategy);
    }

    //获取对应的策略方法
    public static AbstractRocketMqStrategy getStrategyNoNull(Integer code) {
        return STRATEGY_MAP.get(code);
    }
}
